<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="pojo.Brand" %><%--  在第一行加入【JSP指令：page,include,taglib】 --%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>品牌管理页</title>
    <style type="text/css">
        h1{
            color: #BBEFA1;
        }
        h1 a{
            color: #F4CD92;
        }
        table{
            width: 100%;
            border-collapse: collapse;
        }
        table td{
            border: 1px solid #EB9BD5;
            text-align: center;
            color: #F4B2B2;
        }
        table tr{
            color: #816E6E;
        }
        w{
            width: 100px;
        }



    </style>
</head>
<body>
<h1>${LOGIN_USER.username},欢迎您!!
    <a href="${ctx}/logout" style="text-decoration: none" >[注销]</a>
</h1>
<div class="w" style="color: #816E6E">
    状态：
    <select style="background: #D9E8F8" >
        <option >全部状态</option>
        <option >启用</option>
        <option >禁用</option>
    </select>
    品牌名称:
    <input type="text" placeholder="请输入要查询的关键字">
    <input type="button" value="查询" style="background: #F7F6CA" >
    <input type="reset" value="重置" style="background: #F7F6CA">
    <input type="button" value="新增" id="addBtn" style="float: right;margin-left:  6px;background: #D9E8F8 " >
    <input type="button" value="批量删除" onclick="if(confirm('确定删除?')==false)return false;" id="detBtn" style="float: right;background: #D9E8F8 ">


</div>
<hr style="background-color: #EB9BD5">
<table >
    <tr>
        <th>选择</th>
        <th>序号</th>
        <th>品牌名称</th>
        <th>企业名称</th>
        <th>排序</th>
        <th>品牌介绍</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${pageBean.data}" var="brand">
        <tr>
            <td><input type="checkbox"></td>
            <td>${brand.id}</td>
            <td>${brand.brandName}</td>
            <td>${brand.companyName}</td>
            <td>${brand.ordered}</td>
            <td>${brand.description}</td>
            <td>
                <c:if test="${brand.status == 1}">
                    启用
                </c:if>
                <c:if test="${brand.status == 0}">
                    禁用
                </c:if>
            </td>
            <td>
                <a href="${ctx}/toUpdate?id=${brand.id}" style="color: #76afe8">修改</a>
                    <%--                   <a href="#">删除</a>--%>
                <a href="/brand-demo/delete?id=${brand.id}" onclick="if(confirm('确定删除?')==false)return false;" style="color: #76afe8">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>

<div>
    <jsp:include page="common/pageBar.jsp">
        <jsp:param name="url" value="/selectAll"/>
    </jsp:include>
</div>
<div>
    <span style="color: #F56C6C">当前在线人数是：${applicationScope.OnlineCount}</span>
</div>
</body>
<script>
    function getContextPath() {
        var pathName = document.location.pathname;
        var index = pathName.substr(1).indexOf("/");
        var result = pathName.substr(0,index+1);
        return result;
    }

    let addBtn = document.querySelector("#addBtn");
    addBtn.addEventListener('click',function (){
        window.location.href = getContextPath()+"/addBrand.jsp"
    })


</script>
</html>